//package retrofit.upload;
//
//import java.io.IOException;
//import java.util.List;
//import okhttp3.HttpUrl;
//import okhttp3.Interceptor;
//import okhttp3.Request;
//import okhttp3.Response;
//
//public class UploadProgressInterceptor implements Interceptor {
//
//  private ProgressListener progressListener;
//
//  public UploadProgressInterceptor(ProgressListener progressListener) {
//    this.progressListener = progressListener;
//  }
//
//  @Override public Response intercept(Chain chain) throws IOException {
//    Request request = chain.request();
//    HttpUrl url = request.url();
//    List<String> tags = url.queryParameterValues(ProgressListener.PROGRESS_TAG);
//
//    String tag = (tags != null && tags.size() > 0) ? tags.get(0) : url.toString();  //目前只支持单tag
//
//    if (request.body() == null) {
//      return chain.proceed(request);
//    }
//
//    //取到tag以后删除request中的tag
//    HttpUrl newUrl =
//        url.newBuilder().removeAllQueryParameters(ProgressListener.PROGRESS_TAG).build();
//    Request progressRequest = request.newBuilder()
//        .url(newUrl)
//        .method(request.method(), new ProgressRequestBody(tag, request.body(), progressListener))
//        .build();
//
//    return chain.proceed(progressRequest);
//  }
//}
